import request from "./index";

export const getReleaseList = async () => {
    const result = await request.post('/news/releaseList')
    // console.log(result)
    return result
}


interface InsertNewsParams {
    id?: number,
    newsTitle: string,
    title?: string,
    abstractReal: string,
    classReal: number,
    classModel?: string,
    newsSource?: string,
    newsTime?: string,
    coverImage?: string,
    isSelect?: number,
    addMode: number,
    siteName?: string,
    opPerson?: string,
    createTime?: string,
    pubTime?: string,
    isPublished?: number,
    markContent?: string,
    sourceUrl?: string
}

export const insertNews = async (data: Omit<InsertNewsParams, 'id'>) => {
    const result = await request.post('/news/insertNews', data)
    return result.data
}

export const updateNews = async (data: Partial<InsertNewsParams> & { id: number }) => {
    const result = await request.post('/news/updateNews', data)
    return result
}

interface PublishReleaseListParams {
  waitPubTime?: string,
  issueTitle?: string,
  issueCoverImage?: string,
  issueDescription?: string,
  issuePublishTime?: string,
  issuePublisher?: string
}
export const publishReleaseList = async (data: PublishReleaseListParams) => {
    const result = await request.post('/news/publishReleaseList',data)
    return result
}



export const orderNews = async (data: {id: number, orderNews: number}[]) => {
    const result = await request.post('/news/order', {list :data});
    return result;
}

export const newsIssueTemplate = async () => {
    const result = await request.post('/news/newsIssueTemplate')
    return result
}



export const newsIssueList = async (data: { "current": number, "currentSize": number }) => {
    const result = await request.post('/news/issueList',data)
    return result
}
